/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.config.controller;

import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.common.core.Validator.BaseGroup;
import com.icinfo.cloud.provider.punish.config.dto.ConfigBusiParamMainDto;
import com.icinfo.cloud.provider.punish.config.dto.ConfigBusiParamMainPageRequest;
import com.icinfo.cloud.provider.punish.config.dto.ConfigBusiParamMainUseRequest;
import com.icinfo.cloud.provider.punish.config.dto.RelationWorkflowInfoRequest;
import com.icinfo.cloud.provider.punish.config.model.ConfigBusiParamMain;
import com.icinfo.cloud.provider.punish.config.service.IConfigBusiParamMainService;
import com.icinfo.cloud.provider.punish.config.vo.ConfigBusiParamMainVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 描述: 业务参数配置主表 config_busi_param_main 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月22日
 */
@RestController
@RequestMapping("/config/busiParamMain")
public class ConfigBusiParamMainController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(ConfigBusiParamMainController.class);

    @Autowired
    private IConfigBusiParamMainService configBusiParamMainService;

    /**
     * 【V1.0.0】描述：参数配置分页列表
     * @author liyafeng
     * @date 2022/2/16
     * @param request
     * @return {@link Result < PageResponse< ApprovalFlowMainInfoVo>>}
     */
    @PostMapping("/list")
    public Result<PageResponse<ConfigBusiParamMainVo>> list(@RequestBody @Validated ConfigBusiParamMainPageRequest request) {
        List<ConfigBusiParamMainVo> configBusiParamMainVos=configBusiParamMainService.getConfigBusiParamMainVoList(request);
        return Result.success("查询成功",new PageResponse<>(configBusiParamMainVos));
    }
    /**
     *【V1.0.0】描述：保存参数配置
     * @author liyafeng
     * @date 2022/2/16
     * @param configBusiParamMainDto
     * @return {@link Result< String>}
     */
    @PostMapping("/save")
    public Result<String>  save(@RequestBody ConfigBusiParamMainDto configBusiParamMainDto) {
        return configBusiParamMainService.saveConfigBusiParamMainDto(configBusiParamMainDto);
    }
    /**
     *【V1.0.0】描述：修改参数配置
     * @author liyafeng
     * @date 2022/2/16
     * @param configBusiParamMainDto
     * @return {@link Result< String>}
     */
    @PostMapping("/edit")
    public Result<String>  edit(@RequestBody @Validated(BaseGroup.Update.class) ConfigBusiParamMainDto configBusiParamMainDto) {
        return configBusiParamMainService.editConfigBusiParamMain(configBusiParamMainDto);
    }
    /**
     *【V1.0.0】描述：启用或禁用
     * @author liyafeng
     * @date 2022/2/16
     * @param param
     * @return {@link Result< String>}
     */
    @PostMapping("/edituse")
    public Result<String>  use(@RequestBody @Validated(BaseGroup.Update.class) ConfigBusiParamMainUseRequest param) {
        return configBusiParamMainService.editUse(param);
    }
    /**
     * 【V1.0.0】描述：获取参数配置详情
     * @author liyafeng
     * @date 2022/2/16
     * @param id
     * @return {@link Result}
     */
    @PostMapping("/getDetail/{id}")
    public Result<ConfigBusiParamMain> detail(@PathVariable("id") String id){
        return configBusiParamMainService.getDetail(id);
    }

    /**
     * 根据领域编码、区划编码获取工作流信息
     * @author liyafeng
     * @date 2022/3/5
     * @param request
     * @return {@link Result< String>}
     */
    @PostMapping("/getRelationWorkflowInfo")
    public Result<Map<String,Object>> getRelationWorkflowInfo(@RequestBody @Validated RelationWorkflowInfoRequest request){
        Map<String,Object> resultMap=configBusiParamMainService.getRelationWorkflowInfo(request);
        return Result.success(resultMap);
    }
    /**
     * 描述：根据领域编码、区划编码获取参数配置信息
     * @author liyafeng
     * @date 2022/3/5
     * @param request
     * @return {@link Result< String>}
     */
    @PostMapping("/getConfigBusiParamMainList")
    public Result<List<ConfigBusiParamMain>> getConfigBusiParamMainList(@RequestBody  RelationWorkflowInfoRequest request){
        List<ConfigBusiParamMain> resultMap=configBusiParamMainService.getConfigBusiParamMainList(request);
        return Result.success(resultMap);
    }


}
